package 面试经典150题.双指针;

/**
 * @author tmh
 * @date 2024/4/12 20:22
 * @description https://leetcode.cn/problems/is-subsequence/solutions/1658262/by-jyd-zeph/?envType=study-plan-v2&envId=top-interview-150
 */
public class T392判断子序列 {
    public boolean isSubsequence(String s, String t) {
        if (s.length() == 0) {
            return true;
        }
        for (int i = 0, j = 0; j < t.length(); j++) {
            if (s.charAt(i) == t.charAt(j)) {
                //这个代表的就是遍历完子串s了
                if (++i == s.length()) {
                    return true;
                }
            }
        }
        return false;
    }
}
